package com.smedi.ismedi.inmail.api.dto.request;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotNull;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Date;

/**
 * @className: DingAttendanceProjectOverViewPageRequest
 * @Description: TODO
 * @version: v1.0.0
 * @author: wzx
 * @date: 2022/9/22 9:20
 */

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "钉钉项目考勤 分页 请求")
public class DingAttendanceProjectOverViewPageRequest {

    /**
     * 分页行数
     */
    @NotNull
    @ApiModelProperty(value = "分页行数", example = "10")
    private long size;

    /**
     * 当前页数
     */
    @NotNull
    @ApiModelProperty(value = "当前页数", example = "1")
    private long current;

    /**
     * 排序字段
     */
    @ApiModelProperty(value = "排序字段" , example = "avgAttendanceFloat")
    private String orderBy;

    /**
     * 是否升序
     */
    @ApiModelProperty(value = "是否升序", example = "true")
    private boolean asc;

    /**
     *是否只看不合格项目
     */
    @ApiModelProperty(value = "是否包含合格项目",example = "true")
    private boolean pass;

    @ApiModelProperty(value = "考勤日期",example = "2022-05")
    @JsonFormat(pattern = "yyyy-MM")
    private String time;


    @ApiModelProperty(hidden = true)
    @JsonIgnore
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");

    public String getTime() {
        if (time == null) {
            time = sdf.format(new Date());
        }
        return time;
    }
}